<script>
	function deleteTruageRegister(matvv, makh, ngaydo, date)
	{
		if (confirm("Bạn có chắc chắc hủy Đăng Kí này không?"))
		{
			// TODO: Should be changed to use POST instead GET method
			location.href = "MainProcessing.php?action=deleteTruageReg&makh=" + makh + "&view=1&date=" + date;
		}
	}
</script>

<?
require_once ($_SERVER['DOCUMENT_ROOT']."/control/UpperLower.php");
require_once ($_SERVER['DOCUMENT_ROOT']."/MainProcessing.php");

get_upper_lower();
$connectionstring = ConnectMainDatabase();
//	$dojo_truageRegister = truageRegister();
print("<table width=\"100%\" border=\"0\" cellspacing=\"1\" cellpadding=\"5\" bgcolor=\"#DDDDDD\" class=\"normal\">\n");

print ("<tr>");
//print("<td class='normal' align='center' nowrap><b>Mã TVV</b></td>\n");
//print("<td class='normal' align='center' nowrap><b>Họ Tên TVV</b></td>\n");
print("<td class='normal' align='center' nowrap><b>Họ tên</b></td>\n");
print("<td class='normal' align='center' nowrap><b>Năm Sinh</b></td>\n");
print("<td class='normal' align='center' nowrap><b>Địa Chỉ</b></td>\n");
print("<td class='normal' align='center' nowrap><b>Điện Thoại</b></td>\n");
print("<td class='normal' align='center' nowrap><b>CMND</b></td>\n");
print("<td class='normal' align='center' nowrap><b>Ngày Đo</b></td>\n");
print("<td class='normal' align='center' nowrap><b>Tình Trạng</b></td>\n");
print("<td class='normal' align='center' nowrap><b>Chỉ số A.G.E</b></td>\n");
print("<td class='normal' align='center' nowrap><b>Chỉ số TruAge</b></td>\n");
print("<td class='normal' align='center' nowrap><b>Chức năng</b></td>\n");
print ("</tr>");
//if (isset($_POST['submit']))
//{
	$query = " SELECT *, tvv.hoten as hotentvv, tvv.matvv as mstvv, khachhang.hoten as hotenkh,
							khachhang.diachi as dckh, khachhang.makh as mkh, khachhang.sodt as dtkh
					FROM tvv, khachhang, luotdo 
					WHERE ngaydo <= '$upperbound' AND ngaydo >= '$lowerbound'  
					AND tvv.matvv = luotdo.matvv
					AND khachhang.makh = luotdo.makh
					AND tvv.matvv = ". $_SESSION['matvv'];

	/*	if ($report_type == "ngayvao")
	 $query .= " AND ngayvaocty <= '$upperbound' AND ngayvaocty >= '$lowerbound' ";
		else if($report_type == 'ngaysinh')
		{
		$query .= " AND ngaysinh <= '$upperbound' AND ngaysinh >= '$lowerbound' ";
		}
		else if($report_type != "tatca")
		{
		$query .= " AND bophan = '$report_type' ";
		}*/

	//		$query .= " LIMIT ". ($curPage-1)*$maxRows .",". $maxRows;

	$queryexe = mysql_query($query, $connectionstring);
	$count = 0;

	while ($row = mysql_fetch_array($queryexe)) {
		$strCss = "#FFFFFF";
		if($count%2 == 1){
			$strCss ="#C0E0E6";
		}
		$count++;
		$mstvv = $row{'mstvv'};
		$tentvv = $row{'hotentvv'};
		$tenkh = $row{'hotenkh'};
		$diachikh = $row{'dckh'};
		$dtkh = $row{'dtkh'};
		$ngaydo = $row{'ngaydo'};
		$cmnd = $row{'cmnd'};
		$tinhtrang = $row{'tinhtrang'};
		$chisoage = $row{'chisoage'};
		$chisotruage = $row{'chisotruage'};
		$makh = $row{'mkh'};
		$namsinh = $row{'namsinh'};
		$date = $_REQUEST['date'];
//onmouseover=\"javascript: style.backgroundColor='#F9D180'\"  onmouseout=\"javascript: style.backgroundColor='#D9FFD8'\"		
		print ("<tr bgcolor='". $strCss ."' >" );
//		print ("<td><b>$mstvv</b></td>");
//		print ("<td>$tentvv</td>");
		print ("<td>$tenkh</td>");
		print ("<td align='center'>$namsinh</td>");
		print ("<td width='220px'>$diachikh</td>");
		print ("<td>$dtkh</td>");
		print ("<td>$cmnd</td>");
		print ("<td align='center'>". formatDate($ngaydo, "d-m-Y") ."</td>");
		print ("<td>" .getCustomerRegisterStatus($tinhtrang) ."</td>");
		print ("<td>$chisoage</td>");
		print ("<td>$chisotruage</td>");
		
		// TODO: Should be check the action enable or not
		if ($_SESSION['matvv'] == $mstvv) {
			$delStr = '<a href="javascript: deleteTruageRegister(\''. $matvv .'\', \''. $makh .'\', \''. $ngaydo .'\', \''. $date .'\')" class="viewdid">Xóa</a>';
		}  
		print("<td>$delStr</td>");
		print ("</tr>");
	}

	print ("<tr bgcolor='#FEFEBB' class='normal'>");
	print ("<td><b>Tổng:</b></td>");
	print ("<td colspan=9><b>$count</b></td>");
	
	print ("</tr></table>");
		
//}
?>